<template>
    <div>
        <el-steps :active="active" finish-status="success">
            <el-step title="基础信息"></el-step>
            <el-step title="高级设置"></el-step>
        </el-steps>
        <div class="interspaceH"></div>
        <!--基础信息开始-->
        <div v-if="active==0">
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="150px" class="demo-ruleForm" label-position="left">
                <el-form-item label="线下活动名称" prop="name">
                    <el-input style="width: 220px" v-model="ruleForm.name" placeholder="请输入活动名称" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="线下活动城市" prop="city">
                    <el-select v-model="ruleForm.city" placeholder="请选择活动区域" :disabled="true">
                        <el-option label="上海" value="shanghai"></el-option>
                        <el-option label="北京" value="beijing"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="线下活动开始时间" prop="startData" :disabled="true">
                    <el-date-picker
                            v-model="ruleForm.startData"
                            type="datetime" :disabled="true"
                            placeholder="选择开始时间">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="线下活动结束时间" prop="endData" :disabled="true">
                    <el-date-picker
                            v-model="ruleForm.endData"
                            type="datetime" :disabled="true"
                            placeholder="选择结束时间">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="线下活动负责人" prop="people">
                    <el-select v-model="ruleForm.people" placeholder="请选择负责人" :disabled="true">
                        <el-option label="员工1" value="yuangong1"></el-option>
                        <el-option label="员工2" value="yuangong2"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="线下活动地址" prop="address">
                    <el-input style="width: 220px" v-model="ruleForm.address" placeholder="请输入活动地址" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="线下活动行业分类" prop="fenlei">
                    <el-select v-model="ruleForm.fenlei" placeholder="请选择分类" :disabled="true">
                        <el-option label="教育" value="jiaoyu"></el-option>
                        <el-option label="IT" value="it"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <el-button @click="back">返回</el-button>
            <el-button @click="next1">下一步</el-button>
        </div>
        <!--基础信息结束-->
        <!--高级设置开始-->
        <div v-if="active==1">
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="公司名称" prop="gongsiName">
                    <el-input style="width: 220px" v-model="ruleForm.gongsiName" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="活动介绍" prop="jieshao">
                    <el-input style="width: 220px;" v-model="ruleForm.jieshao" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="活动图片" prop="image">
                    <img style="width: 220px;height: 50px" src="@/views/masket/code/zzx_logo.png">
                </el-form-item>
                <el-form-item label="留资方式:" prop="liuzi">
                    <el-tag :key="tag" v-for="tag in ruleForm.liuzi" closable :disable-transitions="false" @close="handleClose(tag)">
                        {{tag}}
                    </el-tag>
                </el-form-item>
                <el-form-item label="欢迎语" prop="huanyingyu">
                    <div style="display: flex;flex-direction: column">
                        <el-input style="width: 220px" type="textarea" v-model="ruleForm.huanyingyu" :disabled="true" />
                    </div>
                </el-form-item>
                <el-form-item label="标题" prop="biaoti">
                    <el-input style="width: 220px" v-model="ruleForm.biaoti" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="摘要" prop="zhaiyao">
                    <el-input style="width: 220px" v-model="ruleForm.zhaiyao" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="封面" prop="fengmian">
                    <img style="width: 100px;height: 150px" src="@/views/masket/code/zzx_logo.png">
                </el-form-item>
                <el-form-item label="报名用户标签:" prop="baomingyonghu">
                    <el-tag :key="tag" v-for="tag in ruleForm.baomingyonghu" closable :disable-transitions="false" @close="handleClose2(tag)">
                        {{tag}}
                    </el-tag>
                </el-form-item>
                <el-form-item label="线下签到用户标签:" prop="qiandao">
                    <el-tag :key="tag" v-for="tag in ruleForm.qiandao" closable :disable-transitions="false" @close="handleClose3(tag)">
                        {{tag}}
                    </el-tag>
                </el-form-item>
                <el-form-item label="签到二维码设置" prop="erweima">
                    <img style="width: 150px;height: 150px" src="@/views/masket/code/zzx_logo.png">
                </el-form-item>
            </el-form>
            <el-button type="primary" @click="up">上一步</el-button>
            <el-button type="primary" @click="close">审核未通过</el-button>
            <el-button @click="save">审核通过</el-button>
        </div>
        <!--高级设置结束-->
    </div>
</template>

<script>
export default {
    name: "list_add",
    data(){
        return{
            active: 0,
            ruleForm: {
                name: '',
                city: '',
                startData: '',
                endData: '',
                people: '',
                address: '',
                fenlei: '',

                gongsiName: '',
                jieshao: '',
                liuzi: [],
                huanyingyu: '',
                biaoti: '',
                zhaiyao: '',
                baomingyonghu: [],
                qiandao: [],

            },
            //基础信息表单验证
            rules: {
                name: [
                    { required: true, message: '请输入活动名称', trigger: 'blur' },
                    { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }
                ],
                city: [
                    { required: true, message: '请选择活动区域', trigger: 'change' }
                ],
                startData: [
                    { type: 'date', required: true, message: '请选择活动开始时间', trigger: 'change' }
                ],
                endData: [
                    { type: 'date', required: true, message: '请选择活动开始时间', trigger: 'change' }
                ],
                people: [
                    { required: true, message: '请选择负责人', trigger: 'change' }
                ],
                address: [
                    { required: true, message: '请输入活动地址', trigger: 'blur' },
                ],

                gongsiName: [
                    { required: true, message: '请输入公司名称', trigger: 'blur' },
                    { min: 3, max: 15, message: '长度在 3 到 15 个字符', trigger: 'blur' }
                ],
                jieshao: [
                    { required: true, message: '请输入活动介绍', trigger: 'blur' },
                ],
            },
            inputVisible: false,
            inputVisible2: false,
            inputVisible3: false,
            inputValue: '',
            inputValue2: '',
            inputValue3: '',
        }

    },
    methods:{


        //下一步
        next1() {
            if (this.active++ > 2) this.active = 0;
        },
        //上一步
        up(){
            this.active = 0
        },

        //返回
        back() {
            this.$emit("currentHandler","list")
        },
        //保存
        save(){
            this.$message({
                message: '审核通过',
                type: "success"
            })
            this.back()
        },
        close() {
          this.$message({
              message: '审核未通过',
              type: 'success'
          })
            this.back()
        },
        //提交
        submit(){
            this.$message({
                message: '成功创建线下活动',
                type: 'success'
            })
            this.back()
        },
        /*留资方式开始*/
        handleClose(tag) {
            this.ruleForm.liuzi.splice(this.ruleForm.liuzi.indexOf(tag), 1);
        },
        showInput() {
            this.inputVisible = true;
            this.$nextTick(_ => {
                this.$refs.saveTagInput.$refs.input.focus();
            });
        },
        handleInputConfirm() {
            let inputValue = this.inputValue;
            if (inputValue) {
                this.ruleForm.liuzi.push(inputValue);
            }
            this.inputVisible = false;
            this.inputValue = '';
        },
        /*留资方式结束*/
        /*报名用户开始*/
        handleClose2(tag) {
            this.ruleForm.baomingyonghu.splice(this.ruleForm.baomingyonghu.indexOf(tag), 1);
        },
        showInput2() {
            this.inputVisible2 = true;
            this.$nextTick(_ => {
                this.$refs.saveTagInput.$refs.input.focus();
            });
        },
        handleInputConfirm2() {
            let inputValue2 = this.inputValue2;
            if (inputValue2) {
                this.ruleForm.baomingyonghu.push(inputValue2);
            }
            this.inputVisible2 = false;
            this.inputValue2 = '';
        },
        /*报名用户结束*/
        /*签到开始*/
        handleClose3(tag) {
            this.ruleForm.qiandao.splice(this.ruleForm.qiandao.indexOf(tag), 1);
        },
        showInput3() {
            this.inputVisible3 = true;
            this.$nextTick(_ => {
                this.$refs.saveTagInput.$refs.input.focus();
            });
        },
        handleInputConfirm3() {
            let inputValue3 = this.inputValue3;
            if (inputValue3) {
                this.ruleForm.qiandao.push(inputValue3);
            }
            this.inputVisible3 = false;
            this.inputValue3 = '';
        },
        /*签到结束*/
    }
}
</script>

<style scoped>

</style>
